<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
		<link rel="stylesheet" href="styles/screen.css" type="text/css"/>
		<script src="scripts/jquery.js" type="text/javascript"></script>
		<script src="scripts/init.js" type="text/javascript"></script>
		<title>title</title>
	</head>
	<body>
		<h1 id="header">title</h1>
		<ul id="navigation"></ul>
		
		<div class="message">Network calculation utilities.</div>
		<form name="ipConvertForm">
			<p>convert IP to number and vica verse</p>
			<label for="IP">IP</label><br/>
			<input name="IP" type="text" size="50"/><br/>
			<label for="number">number</label><br/>
			<input name="number" type="text" size="50"/><br/>
			<input name="convert" value="Convert" type="button"/>
			<input name="reset" value="Reset" type="reset"/>
		</form>
		<form name="rangeConvertForm">
			<p>convert RANGE to range</p>
			<label for="RANGE">range</label><br/>
			<input name="RANGE" type="text" size="50"/><br/>
			<label for="start">start</label><br/>
			<input name="start" type="text" size="50"/><br/>
			<label for="stop">stop</label><br/>
			<input name="stop" type="text" size="50"/><br/>
			<input name="convert" value="Convert" type="button"/>
			<input name="reset" value="Reset" type="reset"/>
		</form>
		<form name="cidrConvertForm">
			<p>convert CIDR to range</p>
			<label for="cidr">CIDR</label><br/>
			<input name="cidr" type="text" size="50"/><br/>
			<label for="start">start</label><br/>
			<input name="start" type="text" size="50"/><br/>
			<label for="stop">stop</label><br/>
			<input name="stop" type="text" size="50"/><br/>
			<input name="convert" value="Convert" type="button"/>
			<input name="reset" value="Reset" type="reset"/>
		</form>
		<form name="ipGenerateForm">
			<p>generate IPs</p>
			<label for="range">range (CIDR or RANGE notations)</label><br/>
			<input name="range" type="text" size="50"/><br/>
			<label for="IPs">IPs</label><br/>
			<textarea name="IPs" cols="50" rows="10"></textarea><br/>
			<input name="generate" value="Generate" type="button"/>
			<input name="reset" type="reset"/>
		</form>
		
		<script src="../lib/AttackAPI/AttackAPI.js" type="text/javascript"></script>
		<script src="../lib/AttackAPI/NetworkCalculator.js" type="text/javascript"></script>
		<script type="text/javascript">
			$('form[@name="ipConvertForm"] input[@name="convert"]').click(function () {
				var form = $(this).parent().get(0);
				if (form.IP.value) {
					form.number.value = AttackAPI.NetworkCalculator.IPToNumber(form.IP.value);
					form.IP.value = '';
				} else if (form.number.value) {
					form.IP.value = AttackAPI.NetworkCalculator.numberToIP(form.number.value);
					form.number.value = '';
				}
			});
			
			$('form[@name="rangeConvertForm"] input[@name="convert"]').click(function () {
				var form = $(this).parent().get(0);
				var range = AttackAPI.NetworkCalculator.RANGEToRange(form.RANGE.value);
				form.start.value = range.start;
				form.stop.value = range.stop;
			});
			
			$('form[@name="cidrConvertForm"] input[@name="convert"]').click(function () {
				var form = $(this).parent().get(0);
				var range = AttackAPI.NetworkCalculator.CIDRToRange(form.cidr.value);
				form.start.value = range.start;
				form.stop.value = range.stop;
			});
			
			$('form[@name="ipGenerateForm"] input[@name="generate"]').click(function () {
				var form = $(this).parent().get(0);
				var IPs = AttackAPI.NetworkCalculator.generateIPs(form.range.value);
				for (index = 0; index < IPs.length; index++)
					form.IPs.value += IPs[index] + "\n";
			});
		</script>
		
		<p id="footer"><a href="http://www.gnucitizen.org">GNUCITIZEN</a> &copy; 2006 all rights reserved</p>
	</body>
</html>